package com.itheima.Service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.Service.OrderService;
import com.itheima.common.entity.OrderPageVO;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.dao.OrderDao;
import com.itheima.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderDao orderDao;
    /**
     * 分页查询
     * @param
     * @return
     */
    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        List<OrderPageVO> orderList= orderDao.findPage(queryPageBean.getQueryString());
        Page<OrderPageVO> page= (Page<OrderPageVO>) orderList;
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void update(Order order) {
        orderDao.update(order);
    }
}
